﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AAA.Base.Util
{
    public class ArrayHelper
    {
        public static T[] Create<T>(T initValue, int iSize)
        {
            T[] array = (T[])Array.CreateInstance(typeof(T), iSize);
            for (int i = 0; i < array.Length; i++)
                array[i] = initValue;
            return array;
        }

        public static object[] ArrayFromObject(object oSource)
        {
            object[] oValues;

            if (oSource.GetType().IsArray)
            {
                oValues = (object[])oSource;
            }
            else
            {
                oValues = new object[] { oSource };
            }

            return oValues;
        }
    }
}
